package com.darwin.darwinDll.analyze
{
	import com.darwin.darwinDll.core.Config;
	import com.darwin.darwinDll.core.DllItem;
	
	import flash.utils.ByteArray;
	import flash.utils.Dictionary;
	
	/**
	 * DDD文件解析器
	 * @author Roland
	 */
	public class DDDAnalyze implements IAnalyze
	{
		public function DDDAnalyze()
		{
		}
		
		public function getDataList():Dictionary
		{
			return _dddList;
		}
		
		
		private var _dddList:Dictionary = new Dictionary();
		public function analyze(byteArray:ByteArray, dllItem:DllItem, compFn:Function):void
		{
			var dddByteArray:ByteArray = byteArray;
			dddByteArray.uncompress();
			var dataObject:Object = dddByteArray.readObject();
			var dataName:String = dllItem.name;
			if(dllItem.flag == "serverid")
			{
				Config.getInstance().registerMatSheet(dataObject);
			}
			_dddList[dataName] = dataObject;
			dllItem.data = dddByteArray;
			dllItem.result =dataObject;
			dllItem.status = DllItem.STATUS_LOADED;
			if(compFn!=null)
			{
				compFn(dllItem);
			}
		}
		
		/**
		 *	返回Object形式数据 
		 * @param key ddd文件的文件名
		 * @param subKey 二级键值（此处忽略）
		 * @return 
		 * 
		 */
		public function getData(key:String, subKey:String):*
		{
			return _dddList[key];
		}
	}
}